import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'core/app_theme.dart';
import 'pages/main_frame.dart';
import 'providers/auth_provider.dart';
import 'providers/product_provider.dart';
import 'providers/cart_provider.dart';
import 'services/auth_service.dart';
import 'services/product_service.dart';
import 'services/cart_service.dart';
import 'providers/address_provider.dart';
import 'services/address_service.dart';
import 'providers/order_provider.dart';
import 'services/order_service.dart';
import 'route/router.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => AuthProvider(AuthService())),
        ChangeNotifierProvider(
          create: (_) => ProductProvider(ProductService()),
        ),
        ChangeNotifierProvider(create: (_) => CartProvider(CartService())),
        ChangeNotifierProvider(
          create: (_) => AddressProvider(AddressService()),
        ),
        ChangeNotifierProvider(create: (_) => OrderProvider(OrderService())),
      ],
      child: const MyApp(),
    ),
  );
}

// 修改MaterialApp配置
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '电商商城',
      theme: AppTheme.lightTheme,
      home: const MainFrame(),
      debugShowCheckedModeBanner: false,
      onGenerateRoute: AppRouter.generateRoute,
    );
  }
}
